'use strict'
const port = 9530 // 开发环境 前台端口
const backendPort = 9505//开发环境 后台接口

const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  //设置为true 更方便错误定位
  productionSourceMap: false,
  runtimeCompiler: true,

  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('assets@', resolve('src/assets'))
      .set('components@', resolve('src/components'))
      .set('plugins@', resolve('src/plugins'))
      .set('views@', resolve('src/views'))
  },

  devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/api': {
        target: `http://127.0.0.1:${backendPort}`,
        changeOrigin: true,
        secure: true,
        pathRewrite: {
          '^/api': ''
        }
      },
    },

  }
}
